package com.fwj.auth.config.handle;

import com.alibaba.fastjson.JSON;
import com.fwj.core.common.model.ResponseDTO;
import org.springframework.http.MediaType;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: fwj
 * @Data: 2022/4/21 22:36
 * @Version 1.0
 * @Description:
 */


public class ResponseUtil {
    public static void response(HttpServletResponse resp, ResponseDTO responseDTO) throws IOException {
        //直接输出的时候还是需要使用UTF-8字符集
        resp.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
        PrintWriter out = resp.getWriter();
        out.write(JSON.toJSONString(responseDTO));
        out.flush();
    }
}
